package com.hundsun.hsOffer.freemarker;

import com.hundsun.hsOffer.model.OfferCompany;
import com.hundsun.hsOffer.model.SysDict;
import com.hundsun.hsOffer.utils.StringUtils;
import freemarker.core.Environment;
import freemarker.template.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * Create By IDEA
 * User:giegie
 * Date:2016/9/4
 * Description: 公司名称标签
 */
public class CompanyDirective implements TemplateDirectiveModel{
    /**
     *
     * @param environment
     * @param map
     * @param templateModels
     * @param templateDirectiveBody
     * @throws TemplateException
     * @throws IOException
     */
    public void execute(Environment environment, Map map, TemplateModel[] templateModels, TemplateDirectiveBody templateDirectiveBody) throws TemplateException, IOException {
        List<OfferCompany> companyList = OfferCompany.dao.findAllCompany();
            environment.setVariable("companyList", ObjectWrapper.DEFAULT_WRAPPER.wrap(companyList));
        if (templateDirectiveBody != null){
            templateDirectiveBody.render(environment.getOut());
        }
    }
}
